fix: show the alarm label in the upcoming-alarm notification#469
Open
MiMoHo wants to merge 1 commit into
Open
Conversation
The upcoming-alarm notification only displayed the day and time from getClosestEnabledAlarmString, which is shared with the clock UI and digital widget and intentionally omits the label. Look up the specific alarm by its ALARM_ID (already passed via the PendingIntent) in UpcomingAlarmReceiver and append its label to the notification content text when present, leaving the shared helper untouched. Closes FossifyOrg#183
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Type of change(s)
What changed and why
The "Upcoming Alarm" notification (shown ~10 minutes before an alarm fires) only displayed the day and time, never the alarm's label. Its content text was set from
Context.getClosestEnabledAlarmString, which by design produces only a"$dayOfWeek $formattedTime"string (e.g. "Mon 07:30"). That helper is intentionally shared with the in-app "next alarm" text (ClockFragment) and the digital home-screen widget (MyDigitalTimeWidgetProvider), both of which should keep showing only the time, so the label must not be appended there.The fix is localized to
UpcomingAlarmReceiver, which already receives the specificALARM_IDthrough its PendingIntent. It now looks up that alarm by id (context.dbHelper.getAlarmWithId(alarmId)?.label) on the existinggoAsyncbackground (Dispatchers.IO) thread and appends the label to the notification content text as"$alarmString - $label"only when a label is present. When the alarm has no label, the notification text is unchanged. No shared code paths are affected.Tests performed
Verified on a real Android 15 (API 35) emulator with the
fossdebug build installed. I created an enabled alarm scheduled a few minutes in the future and droveUpcomingAlarmReceiverfor that alarm id, exactly asAlarmManagerdoes ~10 minutes before an alarm fires. With the alarm labeled "Standup meeting", the posted "Upcoming alarm" notification's content text readSat 12:17 AM - Standup meeting(confirmed both indumpsys notificationand visually in the notification shade). Repeating with the label cleared producedSat 12:17 AMwith no trailing" - "separator, and the sharedgetClosestEnabledAlarmStringoutput (theSat 12:17 AMportion) never contained the label — proving the change is localized to the receiver and the in-app "next alarm"/widget text is untouched. CI (detekt, lint, unit tests, build) also passes.Closes the following issue(s)
Checklist
CHANGELOG.md(if applicable).Coded with Opus 4.8 ultracode.